package com.atguigu.sop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class myadvice {

    @Pointcut("execution(void com.atguigu.Dao.BookDao.update())")
    public void pt(){}

    @Around("myadvice.pt()")
    public Object method(ProceedingJoinPoint pjp) throws Throwable {
        Long startTime = System.currentTimeMillis();
        System.out.println("start");
        for(int i=0;i<1000;i++){
            pjp.proceed();
        }
        System.out.println("end");
        Long endTime = System.currentTimeMillis();
        System.out.println("千次执行时间为"+(endTime-startTime));
        return pjp.proceed();
    }
}
